from devicetest.api import Asserts
from devicetest.aw.OpenHarmony import CommonOH
from devicetest.core.test_case import TestCase, Step

from aw.common import common_setup, common_teardown
from aw.pom import Calculator


class PreTest_RK3568_Tooling_Calculator_0300(TestCase, Calculator):
    # 预置条件：
    # 烧写目标版本后，正常进入桌面-计算器应用
    # 测试步骤：
    # 点击左上角返回按钮
    # 预期结果：
    # 可正常返回至桌面

    def __init__(self, controllers):
        self.TAG = self.__class__.__name__
        TestCase.__init__(self, self.TAG, controllers)

    def setup(self):
        common_setup(self.Phone1)

    def process(self):

        Step('步骤1：进入计算器应用，点击左上角返回按钮')
        CommonOH.startAbility(self.Phone1, self.ability_name, self.bundle_name)
        CommonOH.wait(self.Phone1, 2)
        try:
            CommonOH.touchByText(self.Phone1, '允许')
        except:
            pass
        CommonOH.click(self.Phone1, **self.left_back)
        CommonOH.wait(self.Phone1, 1)
        Step('预期结果1：可正常返回至桌面')
        CommonOH.checkIfTypeExist(self.Phone1, 'Badge')

    def teardown(self):
        common_teardown(self.Phone1, self.bundle_name)
